function Luutam(idBan, idMon, soluong, obMon)
{
	var fdata = {idBan: idBan, idMon: idMon, soluong :soluong}; //Array 
	$.ajax({
		url : _baseURL + "api/index/luutam",
		type: "POST",
		data: fdata,
		success: function(data, textStatus, jqXHR)
		{
			data = $.parseJSON(data);
			
			var oTable = $('#tbOrder').DataTable();
			oTable.row.add( [ obMon[0].Ten, 1, FormatNumber(obMon[0].GiaBan), FormatNumber(obMon[0].GiaBan), '<input class="chonthanhtoan" idLuutam="'+ data +'" type="checkbox" checked="true" value="'+ data +'" />', '<a href="javascript:void(0)" giaban="'+ obMon[0].GiaBan +'" idorder="'+ obMon[0].Id +'" class="btn btn-danger  btn-sm delete">Xóa</a>  <a href="javascript:;" class="btn btn-primary btn-sm accept" onclick="updateTrangthaiOrder('+ obMon[0].Id +')">Hoàn Thành</a>'] ).draw();
			//oTable.row.add( [value.Ten, value.Soluong, FormatNumber(value.GiaBan), FormatNumber(value.GiaBan), '<input onclick="capnhatthanhtien(this, '+ value.GiaBan  +')" class="chonthanhtoan" dataid="'+ value.Id +'" type="checkbox" checked="true" value="'+ value.Id +'" />', '<a href="javascript:void(0)" giaban="'+ value.GiaBan +'" idorder="'+ value.Id +'" class="btn btn-danger  btn-sm delete">Xóa</i></a> <a href="javascript:;" class="btn btn-primary btn-sm accept" onclick="updateTrangthaiOrder('+ value.Id +')">Hoàn Thành</a>' ] ).draw();
			$("#txtThanhtien").val(parseFloat($("#txtThanhtien").val()) + parseFloat(obMon[0].GiaBan));
			$("#txtThanhtoan").val(parseFloat($("#txtThanhtien").val()) - ((parseFloat($("#txtThanhtien").val())*parseFloat($("#txtgiamgia").val()))/100));
		},
		error: function (jqXHR, textStatus, errorThrown)
		{
			alert('Chọn món bị lỗi, vui lòng thử lại');
		}
	});
}


function XoaOrderItem(idOrder, giaban)
{
	//Delete Order Row
	$.ajax({
		url : _baseURL + "api/index/deletorderbyid/idorder/" + idOrder,
		type: "POST",
		data: "",
		success: function(data, textStatus, jqXHR)
		{
			var giacapnhat = parseFloat($("#txtThanhtien").val())  -  parseFloat(giaban);			
			
			$("#txtThanhtien").val( giacapnhat );
		},
		error: function (jqXHR, textStatus, errorThrown)
		{
			alert('Xóa thất bại');
		}
	});	
}


function HuyOrder(idBan, giaban)
{
	//Huy Order 
		
	$.ajax({
		url : _baseURL + "api/index/cancelorder/idBan/" + idBan,
		type: "POST",
		data: "",
		success: function(data, textStatus, jqXHR)
		{
			var giacapnhat = parseFloat($("#txtThanhtoan").val())  -  parseFloat(giaban);
			$("#txtThanhtoan").val( giacapnhat );
		},
		error: function (jqXHR, textStatus, errorThrown)
		{
			alert('Xóa thất bại');
		}
	});	
}